# encoding=utf8

import sys
import array
import math
reload(sys)
sys.setdefaultencoding('utf8')
from ..MessageAnalysis import*

class JT_0200:
    WarnInfo = ["非法开门报警", "侧翻预警", "碰撞预警", "车辆非法位移", "车辆非法点火", "车辆被盗(通过车辆防盗器)", "车辆油量异常","车辆VSS故障", "路线偏离报警", "路段行驶时间不足/过长", "进出路线", "进出区域", "超时停车", "当天累计驾驶超时", "线束断开", "行驶中车厢密闭装置未闭合", "未按指定区域倾倒", "疲劳驾驶预警", "超速预警","道路运输证IC卡模块故障", "摄像头故障", "TTS模块故障", "终端LCD或显示器故障", "终端主电源掉电", "终端主电源欠压", "GNSS天线短路", "GNSS天线未接或被剪断","GNSS模块发生故障", "危险预警", "疲劳驾驶", "超速报警", "紧急报警" ]
    zdy=""
    StatusInfo = [ [ "保留", "保留" ], [ "车箱未举升", "车箱举升" ], [ "密闭装置闭合", "密闭装置开启" ], [ "保留", "保留" ],[ "保留", "保留" ], [ "保留", "保留" ], [ "保留", "保留" ], [ "保留", "保留" ], [ "保留", "保留" ], [ "保留", "保留" ],[ "未使用Galileo卫星进行定位", "使用Galileo卫星进行定位" ], [ "未使用GLONASS卫星进行定位", "使用GLONASS卫星进行定位" ],[ "未使用北斗卫星进行定位", "使用北斗卫星进行定位" ], [ "未使用GPS卫星进行定位", "使用GPS卫星进行定位" ], [ "门5关", "门5开" ],[ "门4关", "门4开" ], [ "门3关", "门3开" ], [ "门2关", "门2开" ], [ "门1关", "门1开" ], [ "车门解锁", "车门加锁" ],[ "车辆电路正常", "车辆电路断开" ], [ "车辆油路正常", "车辆油路断开" ], [ "空车", "半载", "保留", "满载" ], [ "空车", "半载", "保留", "满载" ],[ "保留", "保留" ], [ "保留", "保留" ], [ "经纬度未经保密插件加密", "经纬度已经保密插件加密" ], [ "运营状态", "停运状态" ], [ "东经", "西经" ],[ "北纬", "南纬" ], [ "未定位", "已定位" ], [ "ACC关", "ACC开" ] ]

    LoacDateTypeScr = ["正常位置批量汇报","盲区补报"]
    LocalTypeInfoStr = ["无特定位置","圆形区域","矩形区域","多边形区域","路段"]

    DirectionStr = ["进","出"]
    AnalysisDrivResaulStr = ["不足","过长"]
    VideoAlarmInfo = ["保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","特殊报警录像达到存储阈值报警","异常驾驶行为报警","客车超员报警","其他视频设备故障报警","存储单元故障报警","视频信号遮挡报警","视频信号丢失报警"];
    VideoSigPassInfo = ["视频逻辑通道32","视频逻辑通道31","视频逻辑通道30","视频逻辑通道29","视频逻辑通道28","视频逻辑通道27","视频逻辑通道26","视频逻辑通道25","视频逻辑通道24","视频逻辑通道23","视频逻辑通道22","视频逻辑通道21","视频逻辑通道20","视频逻辑通道19","视频逻辑通道18","视频逻辑通道17","视频逻辑通道16","视频逻辑通道15","视频逻辑通道14","视频逻辑通道13","视频逻辑通道12","视频逻辑通道11","视频逻辑通道10","视频逻辑通道9","视频逻辑通道8","视频逻辑通道7","视频逻辑通道6","视频逻辑通道5","视频逻辑通道4","视频逻辑通道3","视频逻辑通道2","视频逻辑通道1"];

    MemoryFaultInfo = ["第4个灾备存储装置","第3个灾备存储装置","第2个灾备存储装置","第1个灾备存储装置","第12个主存储器","第11个主存储器","第10个主存储器","第9个主存储器","第8个主存储器","第7个主存储器","第6个主存储器","第5个主存储器","第4个主存储器","第3个主存储器","第2个主存储器","第1个主存储器"];

    AbnormalDrivingInfo = [ [ "保留", "保留" ], [ "保留", "保留" ], [ "保留", "保留" ],[ "保留", "保留" ], [ "保留", "保留" ], [ "保留", "保留" ], [ "保留", "保留" ],[ "保留", "保留" ], [ "保留", "保留" ], [ "保留", "保留" ], [ "保留", "保留" ], [ "保留", "保留" ], [ "保留", "保留" ],[ "无抽烟", "有抽烟" ], [ "无打电话", "有打电话" ], [ "无疲劳", "有疲劳" ] ];

    SignalStateInfo = ["保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","离合器状态","加热器工作","ABS 工作","缓速器工作","空挡信号","空调状态","喇叭信号","示廓灯","雾灯信号","倒档信号","制动信号","左转向灯信号","右转向灯信号","远光灯信号","近光灯信号"];
    IOStateInfo = ["保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","休眠状态","深度休眠状态"];
    #FlagBitInfo = [ [ "保留", "紧急" ], [ "保留", "保留" ], [ "保留", "终端显示器显示" ],[ "保留", "终端TTS播读" ], [ "保留", "广告屏显示" ], [ "中心导航信息", "CAN故障码信息" ], [ "保留", "保留" ],[ "保留", "保留" ] ];
    FlagBitInfo = ["保留","保留","保留","广告屏显示","终端TTS播读","终端显示器显示","保留","紧急"];
    result = []
    str=""
    analysisDescription = ['报警标志:', '状态:', '纬度:','经度:','高程:', '速度:', '方向:','时间:']
    #字段长度，以字节为单位
    analysis0200Length=[4,4,4,4,2,2,2,6]
    
    WarnStrInfo = ""
    StatusStrInfo = ""
    LatStrInfo = ""
    LongStrInfo = ""
    HeightStrInfo = ""
    SpeedStrInfo = ""
    DireStrInfo = ""
    TimeStrInfo = ""

    MileStrInfo =""
    OilStrInfo = ""
    VdrSpdStrInfo = ""
    WarnEventIdStrInfo = ""
    RegOrRoadID = ""

    LocalTypeInfoStr = ["无特定位置","圆形区域","矩形区域","多边形区域","路段"];
    OverSpdAddInfoLocTypStrInfo =""
    InOutRegionAddInfoLocTypStrInfo=""
    DirectionInfoStr = ""
    DirectionStr = ["进","出"]
    DrivTimeAddInfoRoadID = ""
    DrivTimeAddInfoDrivTime =""
    AnalysisDrivResaulStr = ["不足","过长"]
    DrivTimeAddInfoResaul = ""
    VideoAlarmStrInfo = ""
    VideoSigMissStrInfo = ""
    VideoSigCoverStrInfo = ""
    MemoryFaultStrInfo = ""
    AbnormalDrivingStrInfo = ""
    FatigueDegreeStrInfo = ""
    SignalStateStrInfo = ""
    IOStateStrInfo = ""
    SSI = ""
    GnssSatelliteNum = ""
    

    def LogicAisle(self, protocolStr, header):
        print "header0001=%s"%header[1].split(':')[1]
        count = 0
        for i in range(len(self.analysisDescription)):
            
            str=protocolStr[count:count + (self.analysis0200Length[i] * 2)]
            if(i==0):
                str=self.hexstrtobin(self.analysis0200Length[i],str)
                self.AnalysisWarnFlagBits(str)
                header.append(self.analysisDescription[i] + self.WarnStrInfo + "\n")
            elif(i==1):
                str=self.hexstrtobin(self.analysis0200Length[i],str)
                self.AnalysisStatusFlagBits(str)
                header.append(self.analysisDescription[i] + self.StatusStrInfo + "\n")
            elif(i==2):
                self.AnalysisLat(str)
                header.append(self.analysisDescription[i] + self.LatStrInfo + "\n")
            elif(i==3):
                self.AnalysisLong(str)
                header.append(self.analysisDescription[i] + self.LongStrInfo + "\n")
            elif(i==4):
                self.AnalysisHeight(str)
                header.append(self.analysisDescription[i] + self.HeightStrInfo + "\n")
            elif(i==5):
                self.AnalysisSpeed(str)
                header.append(self.analysisDescription[i] + self.SpeedStrInfo + "\n")
            elif(i==6):
                self.AnalysisDire(str)
                header.append(self.analysisDescription[i] + self.DireStrInfo + "\n")
            elif(i==7):
                self.AnalysisTime(str)
                header.append(self.analysisDescription[i] + self.TimeStrInfo + "\n")
            count = count + self.analysis0200Length[i] * 2
        start_pos = 56;#82-26
        while True:
            print("do start_pos=%d"%start_pos);
            print("do type(start_pos)=%s"%type(start_pos));
            TypeID = protocolStr[start_pos:start_pos+2];
            start_pos = start_pos + 2;
            if (TypeID == "e0"):
                start_pos = start_pos + 2
            else:
                TypeLen = protocolStr[start_pos:start_pos+2];
                print("TypeLen=%s"%TypeLen);
                start_pos = start_pos + 2;
            
                LocalAdditionalInfo=protocolStr[start_pos:start_pos+(int(TypeLen,16)*2)];
                print("LocalAdditionalInfo=%s"%LocalAdditionalInfo);
                add_header=self.HandleAdditionalInfo(TypeID,TypeLen, LocalAdditionalInfo,header);
                start_pos  = start_pos + int(TypeLen,16)*2;
                LocAddInfoEnd=protocolStr[start_pos+2:start_pos+4];
                if(LocAddInfoEnd=="7e"):
                    break

        self.result = add_header
    def hexstrtobin(self,len,str):
    #转换为二进制字符串
        s=bin(int(str,16))
        #位数不足补零
        n=int(s[2:])
        n="%032d"%n
        print "hexstrtobin.n=%s"%n
        print "hexstrtobin.n.type=%s"%type(n)
        #s=str(n)
        #print "hexstrtobin.s.type=%s"%type(s)
        return n
    def hexstrtobin2(self,len,str):
    #转换为二进制字符串
        s=bin(int(str,16))
        #位数不足补零
        n=int(s[2:])
        n="%016d"%n
        print "hexstrtobin.n=%s"%n
        print "hexstrtobin.n.type=%s"%type(n)
        #s=str(n)
        #print "hexstrtobin.s.type=%s"%type(s)
        return n
    def hexstrtobin3(self,len,str):
    #转换为二进制字符串
        s=bin(int(str,16))
        #位数不足补零
        n=int(s[2:])
        n="%024d"%n
        print "hexstrtobin.n=%s"%n
        print "hexstrtobin.n.type=%s"%type(n)
        #s=str(n)
        #print "hexstrtobin.s.type=%s"%type(s)
        return n

    def hexstrtobin4(self,len,str):
    #转换为二进制字符串
        s=bin(int(str,16))
        #位数不足补零
        n=int(s[2:])
        n="%032d"%n
        print "hexstrtobin.n=%s"%n
        print "hexstrtobin.n.type=%s"%type(n)
        #s=str(n)
        #print "hexstrtobin.s.type=%s"%type(s)
        return n
    
    def WarnInfoAnaly(self,num):
        if(self.WarnInfo[num] != "保留"):
            self.WarnStrInfo += self.WarnInfo[num];
            self.WarnStrInfo += "; \n";
    def AnalysisWarnFlagBits(self,source):
        print("AnalysisWarnFlagBits.source=%s"%source);
        print type(source)
        #chars = array.array( 'u', source );
        #char[] chars = source.toCharArray();
        chars =list(source)
        print type(chars)
        print("AnalysisWarnFlagBits.chars=%s"%chars[2]);
        print("AnalysisWarnFlagBits.chars=%d"%len(chars));
        k = True;
        for i in range(len(chars)):
            print("AnalysisWarnFlagBits.chars=%s"%chars[i]);
            if (chars[i] == '1'):
                self.WarnInfoAnaly(i);
                k = False;
        
        if (k):
            self.WarnStrInfo = "无 \n";
    def StatusInfoAnaly(self, i, j) :
        print ("StatusInfoAnaly.i=%s"%i);
        print ("StatusInfoAnaly.j=%s"%j);
        if(self.StatusInfo[i][j] != "保留"):
            self.StatusStrInfo += self.StatusInfo[i][j];
            self.StatusStrInfo += "; \n";
        
    def AnalysisStatusFlagBits(self, source):
        #char[] chars = source.toCharArray();
        #chars = array.array( 'u', source );
        chars = list(source)
        bit8_9 = "";
        print("AnalysisStatusFlagBits.source=%s\n"%source);
        print("AnalysisStatusFlagBits.chars=%s\n"%len(chars));
        for i in reversed(range(len(chars))):
            print("AnalysisStatusFlagBits.i=%s\n"%i);
            print("AnalysisStatusFlagBits.chars=%s\n"%chars[i]);
            if ((len(chars) - i) == 9 or (len(chars) - i) == 10):
                print("AnalysisStatusFlagBits.bit8_9=%s\n"%bit8_9);
                #bit8_9 += String.valueOf(chars[i]);
                bit8_9 += str(chars[i]);
                print("AnalysisStatusFlagBits.bit8_9=%s\n"%bit8_9);
                if((len(chars) - i) == 10):
                    print("hkkkkkkkkkkkkkkkAnalysisStatusFlagBits.bit8_9=%s\n"%bit8_9);
                    if(bit8_9=="00"):
                        print("hhhhhhhhhhAnalysisStatusFlagBits.bit8_9=%s\n"%bit8_9);
                        self.StatusInfoAnaly(i, 0);
                    elif(bit8_9=="01"):
                        self.StatusInfoAnaly(i, 1);
                    elif(bit8_9=="10"):
                        self.StatusInfoAnaly(i, 2);
                    elif(bit8_9=="11"):
                        self.StatusInfoAnaly(i, 3);
                continue;
            
            #self.StatusInfoAnaly(i, Character.getNumericValue(chars[i]));
            #self.StatusInfoAnaly(i, int(chars[i],16));
            self.StatusInfoAnaly(i, int(chars[i]));
    def AnalysisLat(self, source):
        #double Lat;
        try:
            Lat = int(source,16) * math.pow(10,-6);
            #self.LatStrInfo = String.format("%.6f", Lat);
            self.LatStrInfo = "%.6f"%Lat
        except:
            pass
    def AnalysisLong(self, source):
        #double Long;
        try:
            Long = int(source,16) * math.pow(10,-6);
            #self.LongStrInfo = String.format("%.6f", Long);
            self.LongStrInfo = "%.6f"%Long
        except:
            pass
    def AnalysisHeight(self, source):
        #int height;
        try :
            height = int(source,16);
            self.HeightStrInfo = str(height);
        except:
            pass
    def AnalysisSpeed(self, source):
        #double speed;
        try:
            speed = int(source,16)  * math.pow(10,-1);
            #SpeedStrInfo = String.format("%.2f", speed);
            self.SpeedStrInfo = "%.2f"%speed
        except:
            pass

    def AnalysisDire(self, source):
        #int Dire;
        try :
            Dire = int(source,16);
            #DireStrInfo = String.valueOf(Dire);
            self.DireStrInfo = str(Dire);
        except:
            pass
    def AnalysisTime(self, source):
        #StringBuilder sb = new StringBuilder (source);
        #sb.insert(0, "20");
        #sb.insert(4, "年");
        #sb.insert(7, "月");
        #sb.insert(10, "日");
        #sb.insert(13, "时");
        #sb.insert(16, "分");
        #sb.insert(19, "秒");
        #TimeStrInfo = sb.toString();
        timelist=list(source)
        timelist.insert(0,"20")
        timelist.insert(3,"年")
        timelist.insert(6,"月")
        timelist.insert(9,"日")
        timelist.insert(12,"时")
        timelist.insert(15,"分")
        timelist.insert(18,"秒")
        self.TimeStrInfo = "".join(timelist)
    def HandleAdditionalInfo(self, LocAddInfoTyp, TypeLen, LocaAddInfo,header):
        addHeader =header
        print ("HandleAdditionalInfo addHeader:%s"%addHeader );
        print(LocaAddInfo)
        if(LocAddInfoTyp == ""):
            return;
        
        print("HandleAdditionalInfo LocAddInfoTyp:%s"%LocAddInfoTyp );
        if (LocAddInfoTyp == "01"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            addHeader=self.AnalysisMil(LocaAddInfo,addHeader);
            return addHeader
        elif(LocAddInfoTyp == "02"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            addHeader=self.AnalysisOil(LocaAddInfo,addHeader);
            return addHeader
        elif(LocAddInfoTyp == "03"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            addHeader=self.AnalysisVdrSpd(LocaAddInfo,addHeader);
            return addHeader
        elif(LocAddInfoTyp == "04"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            addHeader=self.AnalysisQueWarnEvent(LocaAddInfo,addHeader);
            return addHeader
        elif(LocAddInfoTyp == "11"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            addHeader=self.AnalysisOverSpdAddInfo(TypeLen,LocaAddInfo,addHeader);
            return addHeader
        elif(LocAddInfoTyp == "12"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            addHeader = self.AnalysisInOutRegionAddInfo(LocaAddInfo,addHeader);
            return addHeader
        elif(LocAddInfoTyp == "13"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            addHeader = self.AnalysisDrivTimeAddInfo(LocaAddInfo,addHeader);
            return addHeader
        elif(LocAddInfoTyp == "14"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            source=self.hexstrtobin(4,LocaAddInfo)
            addHeader = self.AnalysisVideoAlarmFlagBits(source,addHeader);
            return addHeader
        elif(LocAddInfoTyp == "15"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            source=self.hexstrtobin(4,LocaAddInfo)
            addHeader = self.AnalysisVideoSigMissFlagBits(source,addHeader);
            return addHeader
        elif(LocAddInfoTyp == "16"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            source=self.hexstrtobin(4,LocaAddInfo)
            addHeader = self.AnalysisVideoSigCoverFlagBits(source,addHeader);
            return addHeader
        elif(LocAddInfoTyp == "17"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            source=self.hexstrtobin2(2,LocaAddInfo)
            addHeader = self.AnalysisMemoryFaultFlagBits(source,addHeader);
            return addHeader
        elif(LocAddInfoTyp == "18"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            source=self.hexstrtobin3(3,LocaAddInfo)
            addHeader = self.AnalysisAbnormalDrivingFlagBits(source,addHeader);
            return addHeader
        elif(LocAddInfoTyp == "25"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            source=self.hexstrtobin(4,LocaAddInfo)
            addHeader = self.AnalysisSignalStateFlagBits(source,addHeader);
            return addHeader
        elif(LocAddInfoTyp == "2a"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            source=self.hexstrtobin2(2,LocaAddInfo)
            addHeader = self.AnalysisIOStateFlagBits(source,addHeader);
            return addHeader
        elif (LocAddInfoTyp =="2b"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            source = self.hexstrtobin4(4, LocaAddInfo)
            addHeader = self.Analysisanalogquantity(source, addHeader);
            return addHeader
        elif(LocAddInfoTyp == "30"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            addHeader=self.AnalysisSignalInfo(LocaAddInfo,addHeader);
            return addHeader
        elif(LocAddInfoTyp == "31"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            addHeader=self.AnalysisGnssNumInfo(LocaAddInfo,addHeader);
            return addHeader
        elif(LocAddInfoTyp == "eb"):
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            print("III:::->LocaAddInfo:%s" % LocaAddInfo);
            addHeader.append("eb:"+LocaAddInfo+'\n')
            return addHeader
        elif (LocAddInfoTyp == "e0"):
            return addHeader
        elif (LocAddInfoTyp == "e1" and TypeLen == "04"):		#LL添加自定义参数长度判断
            source = self.hexstrtobin4(4, LocaAddInfo)
            print "source e1 reverse before",source
            source = source[::-1]
            print "source e1 reverse after",source
            addHeader = self.zdy1(source, addHeader);
            return addHeader
        elif (LocAddInfoTyp == "e1" and TypeLen == "01"):		#LL添加自定义参数E1一汽
            addHeader = self.zdy1yq(LocaAddInfo, addHeader);	
            return addHeader
        elif (LocAddInfoTyp == "e2" and TypeLen == "04"):		#LL添加自定义参数长度判断
            addHeader.append("保留"+"\n")
            return addHeader
        elif (LocAddInfoTyp == "e2" and TypeLen == "01"):		#LL添加自定义参数E2一汽
            addHeader = self.zdy2yq(LocaAddInfo, addHeader);	
            return addHeader
        elif (LocAddInfoTyp == "e3" and TypeLen != "01"):		#LL添加自定义参数长度判断
            addHeader = self.zdy3(LocaAddInfo, addHeader);
            return addHeader
        elif (LocAddInfoTyp == "e3" and TypeLen == "01"):		#LL添加自定义参数E3一汽
            addHeader = self.zdy3yq(LocaAddInfo, addHeader);	
            return addHeader
        elif (LocAddInfoTyp == "e4" and TypeLen == "02"):		#LL添加自定义参数长度判断
            addHeader = self.zdy4(LocaAddInfo, addHeader);
            return addHeader
        elif (LocAddInfoTyp == "e4" and TypeLen == "01"):		#LL添加自定义参数E4一汽
            addHeader = self.zdy4yq(LocaAddInfo, addHeader);	
            return addHeader
        elif (LocAddInfoTyp == "e5" and TypeLen == "06"):		#LL添加自定义参数长度判断
            addHeader = self.zdy5(LocaAddInfo, addHeader);
            return addHeader
        elif (LocAddInfoTyp == "e5" and TypeLen == "01"):		#LL添加自定义参数E5一汽
            addHeader = self.zdy5yq(LocaAddInfo, addHeader);	
            return addHeader
        elif (LocAddInfoTyp == "e6" and TypeLen == "04"):		#LL添加自定义参数长度判断
            source = self.hexstrtobin4(4, LocaAddInfo)
            addHeader = self.zdy6(source, addHeader);
            return addHeader
        elif (LocAddInfoTyp == "e6" and TypeLen != "04"):		#LL添加自定义参数E6一汽
            addHeader = self.zdy6yq(LocaAddInfo, addHeader);	
            return addHeader
        elif (LocAddInfoTyp == "e7" and TypeLen == "04"):		#LL添加自定义参数长度判断
            addHeader = self.zdy7(LocaAddInfo, addHeader);
            return addHeader
        elif (LocAddInfoTyp == "e7" and TypeLen == "01"):		#LL添加自定义参数E7一汽
            addHeader = self.zdy7yq(LocaAddInfo, addHeader);	
            return addHeader
        elif (LocAddInfoTyp == "e8" and TypeLen == "04"):		#LL添加自定义参数长度判断
            addHeader = self.zdy8(LocaAddInfo, addHeader);
            return addHeader
        elif (LocAddInfoTyp == "e8" and TypeLen == "01"):		#LL添加自定义参数E8一汽
            addHeader = self.zdy8yq(LocaAddInfo, addHeader);	
            return addHeader
        elif (LocAddInfoTyp == "e9" and TypeLen == "04"):		#LL添加自定义参数长度判断
            print(TypeLen)
            addHeader = self.zdy9(LocaAddInfo, addHeader);
            return addHeader
        elif (LocAddInfoTyp == "e9" and TypeLen == "06"):		#LL添加自定义参数E9一汽
            print(TypeLen)
            addHeader = self.zdy9yq(LocaAddInfo, addHeader);	
            return addHeader
        elif (LocAddInfoTyp == "ea"):
            addHeader = self.zdya(LocaAddInfo, addHeader);
            return addHeader
        elif (LocAddInfoTyp == "64"):
            #addHeader = self.zdya(LocaAddInfo, addHeader);
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            print("III:::->LocaAddInfo:%s" % LocaAddInfo);
            addHeader.append("64:" + LocaAddInfo+ "\n")
            return addHeader
        elif (LocAddInfoTyp == "65"):
            #addHeader = self.zdya(LocaAddInfo, addHeader);
            print("III:::->LocAddInfoTyp:%s"%LocAddInfoTyp);
            print("III:::->LocaAddInfo:%s" % LocaAddInfo);
            addHeader.append("65:" + LocaAddInfo+ "\n")
            return addHeader




    def AnalysisMil(self, source,header):
        print("AnalysisMil.header=%s"%header);
        print("AnalysisMil.source=%s"%source);
        header = header
        #double mileage;
        try:
            print("AnalysisMil.try");
            mileage = int(source,16) * math.pow(10,-1);
            print("AnalysisMil.mileage=%d"%mileage);
            #MileStrInfo = String.format("%.1f", mileage);
            self.MileStrInfo = "%.1f"%mileage
            print("AnalysisMil.self.MileStrInfo=%s"%self.MileStrInfo)
            header.append("里程：" + self.MileStrInfo  + "\n")
            print("AnalysisMil.header=%s"%str(header));
            return header
        except:
            pass
    def AnalysisOil(self, source,header):
        print("AnalysisOil.header=%s"%header);
        print("AnalysisOil.source=%s"%source);
        header = header
        #double Oil;
        try:
            print("AnalysisOil.try");
            Oil = int(source,16) * math.pow(10,-1);
            print("AnalysisOil.Oil=%d"%Oil);
            #OilStrInfo = String.format("%.1f", Oil);
            self.OilStrInfo = "%.1f"%Oil
            print("AnalysisOil.self.OilStrInfo=%s"%self.OilStrInfo)
            header.append("油量：" + self.OilStrInfo  + "\n")
            print("AnalysisOil.header=%s"%str(header));
            return header
        except:
            pass
    def AnalysisVdrSpd(self, source,header):
        print("AnalysisVdrSpd.header=%s"%header);
        print("AnalysisVdrSpd.source=%s"%source);
        header = header
        #double vdrspd;
        try:
            print("AnalysisVdrSpd.try");
            vdrspd = int(source,16) * math.pow(10,-1);
            print("AnalysisVdrSpd.vdrspd=%d"%vdrspd);
            #VdrSpdStrInfo = String.format("%.1f", vdrspd);
            self.VdrSpdStrInfo = "%.1f"%vdrspd
            print("AnalysisVdrSpd.self.VdrSpdStrInfo=%s"%self.VdrSpdStrInfo)
            header.append("行驶记录功能获取的速度：" + self.VdrSpdStrInfo  + "\n")
            print("AnalysisVdrSpd.header=%s"%str(header));
            return header
        except:
            pass
    def AnalysisQueWarnEvent(self, source,header):
        #int warneventid;
        try:
            print("AnalysisQueWarnEvent.try");
            warneventid = int(source,16);
            print("AnalysisQueWarnEvent.warneventid=%d"%warneventid);
            #WarnEventIdStrInfo = String.valueOf(warneventid);
            self.WarnEventIdStrInfo = str(warneventid);
            header.append("需要人工确认报警事件的ID：" + self.WarnEventIdStrInfo  + "\n")
            print("AnalysisQueWarnEvent.header=%s"%str(header));
            return header
        except:
            pass
    def AnalysisOverSpdAddInfo(self,TypeLen,source,header):
        typelen =int(TypeLen,16);
        try:
            print("AnalysisOverSpdAddInfo.try");
            print("AnalysisOverSpdAddInfo.typelen=%d"%typelen);
            if (typelen == 1):
                self.OverSpdAddInfoLocTypStrInfo=self.LocalTypeInfoStr[0];
                print("AnalysisOverSpdAddInfo.OverSpdAddInfoLocTypStrInfo=%s"%self.OverSpdAddInfoLocTypStrInfo);
                header.append("超速报警附加信息 位置类型:" + self.OverSpdAddInfoLocTypStrInfo  + "\n")
                print("AnalysisOverSpdAddInfo.header=%s"%header);
                return header
            if (typelen == 5):
                #char[] charsn = source.toCharArray();
                charsn =list(source)
                for i in charsn:
                    print i
                    print("AnalysisOverSpdAddInfo.charsn=%s"%charsn);
                #int id = charsn[1]- 48;
                id_tmp="".join(charsn[0:2])
                print("AnalysisOverSpdAddInfo.id_tmp=%s"%id_tmp);
                id = int(id_tmp,16)
                print("AnalysisOverSpdAddInfo.id=%d"%id);
                self.OverSpdAddInfoLocTypStrInfo=self.LocalTypeInfoStr[id];
                print("AnalysisOverSpdAddInfo.OverSpdAddInfoLocTypStrInfo=%s"%self.OverSpdAddInfoLocTypStrInfo);
                header.append("超速报警附加信息 位置类型:" + self.OverSpdAddInfoLocTypStrInfo  + "\n")
                #char[] cha = {charsn[2],charsn[3],charsn[4],charsn[5],charsn[6],charsn[7],charsn[8],charsn[9]}; 
                chastr="".join(charsn[2:10])
                print("AnalysisOverSpdAddInfo.chastr=%s"%chastr);
                chaint=int(chastr,16)
                print("AnalysisOverSpdAddInfo.chaint=%d"%chaint);
                #RegOrRoadID = String.valueOf(cha);
                self.RegOrRoadID =str(chaint)
                print("AnalysisOverSpdAddInfo.RegOrRoadID=%s"%self.RegOrRoadID);
                header.append("区域或路线ID:" + self.RegOrRoadID  + "\n")
                return header
        except:
            pass
    
    def AnalysisInOutRegionAddInfo(self, source,header):
        try:
            #char[] charsn = source.toCharArray();
            charsn =list(source)
            #int id = charsn[1]- 48;
            id_tmp="".join(charsn[0:2])
            print("AnalysisInOutRegionAddInfo.id_tmp=%s"%id_tmp);
            id = int(id_tmp,16)
            print("AnalysisInOutRegionAddInfo.id=%d"%id);
            self.InOutRegionAddInfoLocTypStrInfo=self.LocalTypeInfoStr[id];
            print("AnalysisInOutRegionAddInfo.InOutRegionAddInfoLocTypStrInfo=%s"%self.InOutRegionAddInfoLocTypStrInfo);
            header.append("进出区域/路线报警附加信息 位置类型:" + self.InOutRegionAddInfoLocTypStrInfo  + "\n")
            #char[] cha = {charsn[2],charsn[3],charsn[4],charsn[5],charsn[6],charsn[7],charsn[8],charsn[9]}; 
            #InOutRegionAddInfoRegOrRoadID = String.valueOf(cha);
            chastr="".join(charsn[2:10])
            print("AnalysisInOutRegionAddInfo.chastr=%s"%chastr);
            chaint=int(chastr,16)
            print("AnalysisInOutRegionAddInfo.chaint=%d"%chaint);
            #RegOrRoadID = String.valueOf(cha);
            self.RegOrRoadID =str(chaint)
            print("AnalysisInOutRegionAddInfo.RegOrRoadID=%s"%self.RegOrRoadID);
            header.append("区域或路线ID:" + self.RegOrRoadID  + "\n")
            Direction_tmp="".join(charsn[10:12])
            print("AnalysisInOutRegionAddInfo.Direction_tmp=%s"%Direction_tmp);
            s=bin(int(Direction_tmp,16))
            print("AnalysisInOutRegionAddInfo.type(s)=%s"%type(s));
            print("AnalysisInOutRegionAddInfo.s=%s"%s);
            print s[2:]
            n=s[2:]
            print("AnalysisInOutRegionAddInfo.type(n)=%s"%type(n));
            print("AnalysisInOutRegionAddInfo.n=%s"%n);
            #n="%02d"%n #01/10
            #print("AnalysisInOutRegionAddInfo.n=%s"%n);
            if(n == "1"):
                self.DirectionInfoStr = self.DirectionStr[0]
                header.append("方向:" + self.DirectionInfoStr  + "\n")
                return header
            elif(n == "10"):
                self.DirectionInfoStr = self.DirectionStr[1]
                header.append("方向:" + self.DirectionInfoStr  + "\n")
                return header
        except:
            pass
    def AnalysisDrivTimeAddInfo(self, source,header):
        try:
            charsn =list(source)
            chastr="".join(charsn[0:8])
            print("AnalysisDrivTimeAddInfo.chastr=%s"%chastr);
            chaint=int(chastr,16)
            print("AnalysisDrivTimeAddInfo.chaint=%d"%chaint);
            self.DrivTimeAddInfoRoadID =str(chaint)
            print("AnalysisDrivTimeAddInfo.DrivTimeAddInfoRoadID=%s"%self.DrivTimeAddInfoRoadID);
            header.append("路段行驶时间不足/过长报警附加信息 路段ID:" + self.DrivTimeAddInfoRoadID  + "\n")
            
            chatime="".join(charsn[8:12])
            print("AnalysisDrivTimeAddInfo.chatime=%s"%chatime);
            chaint=int(chatime,16)
            print("AnalysisDrivTimeAddInfo.chaint=%d"%chaint);
            self.DrivTimeAddInfoDrivTime =str(chaint)
            print("AnalysisDrivTimeAddInfo.DrivTimeAddInfoDrivTime=%s"%self.DrivTimeAddInfoDrivTime);
            header.append("路段行驶时间:" + self.DrivTimeAddInfoDrivTime  + "\n")
            
            DrivTimeAddInfoResaul_tmp="".join(charsn[12:14])
            print("AnalysisDrivTimeAddInfo.Direction_tmp=%s"%DrivTimeAddInfoResaul_tmp);
            s=bin(int(DrivTimeAddInfoResaul_tmp,16))
            print("AnalysisDrivTimeAddInfo.type(s)=%s"%type(s));
            print("AnalysisDrivTimeAddInfo.s=%s"%s);
            print s[2:]
            n=s[2:]
            print("AnalysisDrivTimeAddInfo.type(n)=%s"%type(n));
            print("AnalysisDrivTimeAddInfo.n=%s"%n);
            
            if(n == "1"):
                self.DrivTimeAddInfoResaul = self.AnalysisDrivResaulStr[0]
                header.append("结果:" + self.DrivTimeAddInfoResaul  + "\n")
                return header
            elif(n == "10"):
                self.DrivTimeAddInfoResaul = self.AnalysisDrivResaulStr[1]
                header.append("结果:" + self.DrivTimeAddInfoResaul  + "\n")
                return header
        except:
            pass

    def VideoAlarmAnaly(self,num):
        if(self.VideoAlarmInfo[num] != "保留"):
            self.VideoAlarmStrInfo += self.VideoAlarmInfo[num];
            self.VideoAlarmStrInfo += "; \n";
    def AnalysisVideoAlarmFlagBits(self,source,header):
        print("AnalysisVideoAlarmFlagBits.source=%s"%source);
        print type(source)
        #chars = array.array( 'u', source );
        #char[] chars = source.toCharArray();
        chars =list(source)
        print type(chars)
        print("AnalysisVideoAlarmFlagBits.chars=%s"%chars[2]);
        print("AnalysisVideoAlarmFlagBits.chars=%d"%len(chars));
        k = True;
        for i in range(len(chars)):
            print("AnalysisVideoAlarmFlagBits.chars=%s"%chars[i]);
            if (chars[i] == '1'):
                self.VideoAlarmAnaly(i);
                k = False;
        
        if (k):
            self.VideoAlarmStrInfo = "无 \n";
        header.append("视频相关报警：" + self.VideoAlarmStrInfo  + "\n")
        return header

    def VideoSigMissAnaly(self,num):
        if(self.VideoSigPassInfo[num] != "保留"):
            self.VideoSigMissStrInfo += self.VideoSigPassInfo[num];
            self.VideoSigMissStrInfo += "; \n";
    def AnalysisVideoSigMissFlagBits(self,source,header):
        print("AnalysisVideoSigMissFlagBits.source=%s"%source);
        print type(source)
        #chars = array.array( 'u', source );
        #char[] chars = source.toCharArray();
        chars =list(source)
        print type(chars)
        print("AnalysisVideoSigMissFlagBits.chars=%s"%chars[2]);
        print("AnalysisVideoSigMissFlagBits.chars=%d"%len(chars));
        k = True;
        for i in range(len(chars)):
            print("AnalysisVideoSigMissFlagBits.chars=%s"%chars[i]);
            if (chars[i] == '1'):
                self.VideoSigMissAnaly(i);
                k = False;
        
        if (k):
            self.VideoSigMissStrInfo = "无 \n";
        header.append("视频信号丢失报警：" + self.VideoSigMissStrInfo  + "\n")
        return header
    def VideoSigCoverAnaly(self,num):
        if(self.VideoSigPassInfo[num] != "保留"):
            self.VideoSigCoverStrInfo += self.VideoSigPassInfo[num];
            self.VideoSigCoverStrInfo += "; \n";
    def AnalysisVideoSigCoverFlagBits(self,source,header):
        print("AnalysisVideoSigCoverFlagBits.source=%s"%source);
        print type(source)
        #chars = array.array( 'u', source );
        #char[] chars = source.toCharArray();
        chars =list(source)
        print type(chars)
        print("AnalysisVideoSigCoverFlagBits.chars=%s"%chars[2]);
        print("AnalysisVideoSigCoverFlagBits.chars=%d"%len(chars));
        k = True;
        for i in range(len(chars)):
            print("AnalysisVideoSigCoverFlagBits.chars=%s"%chars[i]);
            if (chars[i] == '1'):
                self.VideoSigCoverAnaly(i);
                k = False;
        
        if (k):
            self.VideoSigCoverStrInfo = "无 \n";
        header.append("视频信号遮挡报警：" + self.VideoSigCoverStrInfo  + "\n")
        return header

    def MemoryFaultAnaly(self,num):
        if(self.MemoryFaultInfo[num] != "保留"):
            self.MemoryFaultStrInfo += self.MemoryFaultInfo[num];
            self.MemoryFaultStrInfo += "; \n";
    def AnalysisMemoryFaultFlagBits(self,source,header):
        print("AnalysisMemoryFaultFlagBits.source=%s"%source);
        print type(source)
        #chars = array.array( 'u', source );
        #char[] chars = source.toCharArray();
        chars =list(source)
        print type(chars)
        print("AnalysisMemoryFaultFlagBits.chars=%s"%chars[2]);
        print("AnalysisMemoryFaultFlagBits.chars=%d"%len(chars));
        k = True;
        for i in range(len(chars)):
            print("AnalysisMemoryFaultFlagBits.chars=%s"%chars[i]);
            if (chars[i] == '1'):
                self.MemoryFaultAnaly(i);
                k = False;
        
        if (k):
            self.MemoryFaultStrInfo = "无 \n";
        header.append("存储器故障报警：" + self.MemoryFaultStrInfo  + "\n")
        return header
    def AbnormalDrivingAnaly(self, i, j):
        if(self.AbnormalDrivingInfo[i][j] != "保留"):
            self.AbnormalDrivingStrInfo += self.AbnormalDrivingInfo[i][j];
            self.AbnormalDrivingStrInfo += "; \n";
    def AnalysisAbnormalDrivingFlagBits(self, source,header):
        #char[] chars = source.toCharArray();
        chars_str=source[0:16]
        chars=list(chars_str)
        print("AnalysisAbnormalDrivingFlagBits.source=%s0"%source);
        print("AnalysisAbnormalDrivingFlagBits=%s"%len(chars));
        for i in reversed(range(len(chars))):
            print("AnalysisAbnormalDrivingFlagBits.i=%d"%i);
            print("AnalysisAbnormalDrivingFlagBits.chars=%s"%chars[i]);
            #AbnormalDrivingAnaly(i, Character.getNumericValue(chars[i]));
            self.AbnormalDrivingAnaly(i,int(chars[i]))
        header.append("异常驾驶行为报警 异常驾驶行为：" + self.AbnormalDrivingStrInfo  + "\n")
        s=source[16:23]
        s=int(s,2)
        self.FatigueDegreeStrInfo = str(s)
        header.append("疲劳程度：" + self.FatigueDegreeStrInfo  + "\n")
        return header
    def SignalStateAnaly(self,num):
        if(self.SignalStateInfo[num] != "保留"):
            self.SignalStateStrInfo += self.SignalStateInfo[num];
            self.SignalStateStrInfo += "; \n";
    def AnalysisSignalStateFlagBits(self,source,header):
        print("AnalysisSignalStateFlagBits.source=%s"%source);
        print type(source)
        #chars = array.array( 'u', source );
        #char[] chars = source.toCharArray();
        chars =list(source)
        print type(chars)
        print("AnalysisSignalStateFlagBits.chars=%s"%chars[2]);
        print("AnalysisSignalStateFlagBits.chars=%d"%len(chars));
        k = True;
        for i in range(len(chars)):
            print("AnalysisSignalStateFlagBits.chars=%s"%chars[i]);
            if (chars[i] == '1'):
                self.SignalStateAnaly(i);
                k = False;
        
        if (k):
            self.SignalStateStrInfo = "无 \n";
        header.append("扩展信号车辆状态位：" + self.SignalStateStrInfo)
        return header
    def IOStateAnaly(self,num):
        if(self.IOStateInfo[num] != "保留"):
            self.IOStateStrInfo += self.IOStateInfo[num];
            self.IOStateStrInfo += "; \n";
    def AnalysisIOStateFlagBits(self,source,header):
        print("AnalysisIOStateFlagBits.source=%s"%source);
        print type(source)
        #chars = array.array( 'u', source );
        #char[] chars = source.toCharArray();
        chars =list(source)
        print type(chars)
        print("AnalysisIOStateFlagBits.chars=%s"%chars[2]);
        print("AnalysisIOStateFlagBits.chars=%d"%len(chars));
        k = True;
        for i in range(len(chars)):
            print("AnalysisIOStateFlagBits.chars=%s"%chars[i]);
            if (chars[i] == '1'):
                self.IOStateAnaly(i);
                k = False;
        
        if (k):
            self.IOStateStrInfo = "无 \n";
        header.append("IO状态位：" + self.IOStateStrInfo)
        return header

    def Analysisanalogquantity(self, source, header):
        chars = list(source)
        c = 0
        k = True;
        for i in range(len(chars)):
            if (chars[i] == '1'):
                k = False;

        if (k):
            header.append("模拟量:无" + "\n")
        else:
            s = source[c:c + 16]
            header.append("模拟量：ADO：" + s + "\n")
            c = c + 16
            s = source[c:c + 16]
            header.append("AD1:" + s + "\n")

        return header

    def AnalysisSignalInfo(self, source,header):
        #int ssi;
        try:
            ssi = int(source,16);
            self.SSI = str(ssi);
            header.append("无线通信网络信号强度：" + self.SSI  + "\n")
            return header
        except:
            pass
    def AnalysisGnssNumInfo(self, source,header):
        #int gnssnum;
        try:
            gnssnum = int(source,16);
            self.GnssSatelliteNum = str(gnssnum);
            header.append("GNSS定位卫星数：" + self.GnssSatelliteNum  + "\n")
            return header
        except:
            pass
    def zdy1(self,source,header):
        header.append("\n" + "自定义状态位：" + "\n")
        s=source[0:1]
        if s=="0":
            header.append(s + " ECU匹配GPS ID失败" + "\n")
        elif s=="1":
            header.append(s + " ECU匹配GPS ID成功" + "\n")
        s = source[1:2]
        if s == "0":
            header.append(s + " 终端与ECU握手校验失败" + "\n")
        elif s == "1":
            header.append(s + " 终端与ECU握手校验成功" + "\n")
        s = source[2:3]
        if s == "0":
            header.append(s + " ECU不在线" + "\n")
        elif s == "1":
            header.append(s + " ECU在线" + "\n")
        s = source[3:5]
        s = s[::-1]
        if s == "00":
            header.append(s + " ECU绑定中" + "\n")
        elif s == "01":
            header.append(s + " ECU已绑定" + "\n")
        elif s == "10":
            header.append(s + " ECU解绑中" + "\n")
        elif s == "11":
            header.append(s + " ECU已解绑" + "\n")
        s = source[5:8]
        s = s[::-1]
        if s == "001":
            header.append(s + " 终端向ECU发送锁车命令中" + "\n")
        elif s == "010":
            header.append(s + " ECU锁车中" + "\n")
        elif s == "011":
            header.append(s + " ECU已锁车" + "\n")
        elif s == "101":
            header.append(s + " 终端向ECU发送解锁命令中" + "\n")
        elif s == "110":
            header.append(s + " ECU解锁中" + "\n")
        elif s == "111":
            header.append(s + " ECU已解锁" + "\n")
        s = source[8:9]
        if s == "0":
            header.append(s + " 未执行绑定条件下的最高转速" + "\n")
        elif s == "1":
            header.append(s + " 执行绑定条件下的最高转速（用于多次握手失败时）" + "\n")
        s = source[9:10]
        if s == "0":
            header.append(s + " 远程紧急启动未执行" + "\n")
        elif s == "1":
            header.append(s + " 远程紧急启动已执行" + "\n")
        s = source[10:11]
        header.append("\n" + "本地紧急启动时的执行结果：" + "\n")
        if s == "0":
            header.append(s + " 本地紧急启动有效" + "\n")
        elif s == "1":
            header.append(s + " 本地紧急启动无效" + "\n")
        s = source[11:12]
        if s == "0":
            header.append(s + " 本地解锁无效状态" + "\n")
        elif s == "1":
            header.append(s + " 本地解锁有效状态" + "\n")
        s = source[12:13]
        if s == "0":
            header.append(s + " 禁用待命延时功能" + "\n")
        elif s == "1":
            header.append(s + " 启用待命延时功能" + "\n")
        s = source[13:14]
        if s == "0":
            header.append(s + " 未处于待命延时状态" + "\n")
        elif s == "1":
            header.append(s + " 处于待命延时状态" + "\n")
        s = source[14:16]
        s = s[::-1]
        if s == "00":
            header.append(s + " 终端无法判断是否具备锁车功能；" + "\n")
        elif s == "01":
            header.append(s + " 具备锁车功能；" + "\n")
        elif s == "10":
            header.append(s + " 不具备锁车功能" + "\n")
        s = source[16:18]
        s = s[::-1]
        header.append("\n" + "车速来源：")
        if s == "00":
            header.append(s + " 仪表" + "\n")
        elif s == "01":
            header.append(s + " CAN车速" + "\n")
        elif s == "10":
            header.append(s + " 脉冲车速" + "\n")
        elif s == "11":
            header.append(s + " GPS车速" + "\n")
        #====================3.5新加不联网锁车是否生效================
        s = source[18:19]
        header.append("不联网锁车是否生效：")
        if s == '0':
            header.append(s + " 未生效" + "\n")
        elif s == '1':
             header.append(s + " 生效" + "\n")
        #====================新加“里程来源”=========================
        s = source[19:22]
        s = s[::-1]
        header.append("里程来源：")
        if s == '000':
            header.append(s + " 未知" + "\n")
        elif s == '001':
            header.append(s + " VDR里程" + "\n")
        elif s == '010':
            header.append(s + " 仪表ICU里程" + "\n")
        elif s == '011':
            header.append(s + " ECM高精度里程" + "\n")
        elif s == '100':
            header.append(s + " ECM低精度里程" + "\n")
        elif s == '101':
            header.append(s + " 脉冲里程" + "\n")
        elif s == '110':
            header.append(s + " GPS里程" + "\n")
        s = source[22:24]
        s = s[::-1]
        #====================3.5新加“设备运行状态”=========================
        header.append("设备运行状态：")
        if s == '00':
            header.append(s + " 无效")
        elif s == '01':
            header.append(s + " 工作状态")
        elif s == '10':
            header.append(s + " 休眠状态")
        elif s == '11':
            header.append(s + " 预留")

        header.append("\n")

        return header

    def zdy3(self, source, header):
        header.append( "数据ID：")
        s=source[0:4]
        header.append(s + "\n")
        s=source[4:6]
        n=int(s,16)
        header.append("数据长度："+str(n) + "\n")
        s=source[6:n*2+6]
        header.append("数据值：" + s + "\n")
        return header
    def zdy4(self, source, header):
        header.append( "发动机类型：")
        s=source[0:4]
        if s=="0000":
            header.append("未知")
        elif s=="0001":
            header.append("潍柴")
        elif s=="0002":
            header.append("福田康明斯")
        elif s=="0003":
            header.append("康明斯平台化")
        elif s=="0004":
            header.append("玉柴")
			
        header.append("\n")
        return header

    def zdy5(self, source, header):
        s=source
        c=0
        t = s[c:c + 2]
        header.append("开始锁车时间：" + t)
        c = c + 2
        for i in range(5):
            t = s[c:c + 2]
            header.append("-" + t)
            c = c + 2
        header.append("\n")
        return header

    def zdy6(self, source, header):
        header.append("轻卡开关量：" + t)
        s = source[0:2]
        if s == "00":
            header.append(s + "EBS 制动开关未起作用" + "\n")
        elif s == "01":
            header.append(s + "EBS 制动开关起作用" + "\n")
        elif s == "10":
            header.append(s + "状态不明" + "\n")
        elif s == "11":
            header.append(s + "无效" + "\n")
        s = source[2:4]
        if s == "00":
            header.append(s + "水温正常" + "\n")
        elif s == "01":
            header.append(s + "水温报警" + "\n")
        elif s == "10":
            header.append(s + "保留" + "\n")
        elif s == "11":
            header.append(s + "无效" + "\n")
        s = source[4:6]
        if s == "00":
            header.append(s + "空滤正常" + "\n")
        elif s == "01":
            header.append(s + "空滤报警" + "\n")
        elif s == "10":
            header.append(s + "保留" + "\n")
        elif s == "11":
            header.append(s + "无效" + "\n")
        s = source[6:8]
        if s == "00":
            header.append(s + "安全带状态正常" + "\n")
        elif s == "01":
            header.append(s + "安全带报警" + "\n")
        elif s == "10":
            header.append(s + "保留" + "\n")
        elif s == "11":
            header.append(s + "无效" + "\n")
        s = source[8:10]
        if s == "00":
            header.append(s + "驾驶室锁止" + "\n")
        elif s == "01":
            header.append(s + "驾驶室未锁止" + "\n")
        elif s == "10":
            header.append(s + "保留" + "\n")
        elif s == "11":
            header.append(s + "无效" + "\n")
        s = source[10:12]
        if s == "00":
            header.append(s + "制动灯正常" + "\n")
        elif s == "01":
            header.append(s + "制动灯故障" + "\n")
        elif s == "10":
            header.append(s + "保留" + "\n")
        elif s == "11":
            header.append(s + "无效" + "\n")
        s = source[12:14]
        if s == "00":
            header.append(s + "气压正常" + "\n")
        elif s == "01":
            header.append(s + "气压过低报警" + "\n")
        elif s == "10":
            header.append(s + "保留" + "\n")
        elif s == "11":
            header.append(s + "无效" + "\n")
        s = source[14:16]
        if s == "00":
            header.append(s + "制动系统正常" + "\n")
        elif s == "01":
            header.append(s + "制动系统故障" + "\n")
        elif s == "10":
            header.append(s + "保留" + "\n")
        elif s == "11":
            header.append(s + "无效" + "\n")
        s = source[16:18]
        if s == "00":
            header.append(s + "真空度正常" + "\n")
        elif s == "01":
            header.append(s + "真空度低报警" + "\n")
        elif s == "10":
            header.append(s + "保留" + "\n")
        elif s == "11":
            header.append(s + "无效" + "\n")
        s = source[18:20]
        if s == "00":
            header.append(s + "制动/离合液位正常" + "\n")
        elif s == "01":
            header.append(s + "制动/离合液位低" + "\n")
        elif s == "10":
            header.append(s + "保留" + "\n")
        elif s == "11":
            header.append(s + "无效" + "\n")
        s = source[20:32]
        header.append("保留"+s)
        return header
    def zdy7(self, source, header):
        header.append( "GPS计算累积里程：")
        s=int(source,16)
        header.append(str(s)+"m" + "\n")
        return header
    def zdy8(self, source, header):
        header.append( "基站数据：")
        s=source[0:2]
        header.append("LAC/TAC:"+s+"  ")
        s=source[2:4]
        header.append("CI:"+s+"\n")
        return header
    def zdy9(self, source, header):
        header.append( "整车总重：")
        s=source[0:2]
        header.append("次数:"+str(int(s,16)))
        s=source[2:4]
        header.append("  等级:"+s)
        if s=="00":
            header.append("空载")
        elif s=="01":
            header.append("半载")
        elif s == "02":
            header.append("重载")
        elif s == "03":
            header.append("超载")
        elif s == "ff":
            header.append("无效")
        s = source[4:6]
        header.append("  吨数:")
        if s=="ff":
            header.append("无效")
        else:
            header.append(str(int(s,16)))
        s = source[6:8]
        header.append("  预留:"+s + "\n")
        return header
    def zdya(self, source, header):
        header.append( "瞬时燃油经济性信号：")
        s=source[0:4]
        header.append(str(int(s,16)) +"\n")
        return header
    def zdy1yq(self, source, header):			#LL以下都是一汽自定义参数解析
        header.append( "发动机转速：")
        #s=int(source,16)
        header.append(str(source)+ "\n")
        return header
    def zdy2yq(self, source, header):
        header.append( "冷却液温度：")
        #s=int(source,16)
        header.append(str(source)+ "\n")
        return header
    def zdy3yq(self, source, header):
        header.append( "发动机进气歧管压力：")
        #s=int(source,16)
        header.append(str(source)+ "\n")
        return header
    def zdy4yq(self, source, header):
        header.append( "发动机进气歧管温度：")
        #s=int(source,16)
        header.append(str(source)+ "\n")
        return header
    def zdy5yq(self, source, header):
        header.append( "发动机机油压力：")
        #s=int(source,16)
        header.append(str(source)+ "\n")
        return header
    def zdy6yq(self, source, header):
        header.append( "轮胎数据：")
        header.append(str(source)+ "\n")
        return header
    def zdy7yq(self, source, header):
        header.append( "尿素液位信号：")
        #s=int(source,16)
        header.append(str(source)+ "\n")
        return header
    def zdy8yq(self, source, header):
        header.append( "油箱液位信号：")
        #s=int(source,16)
        header.append(str(source)+ "\n")
        return header
    def zdy9yq(self, source, header):
        header.append( "总油耗：")
        #s=int(source,16)
        header.append(str(source)+ "\n")
        return header
